﻿

<table class="table table-striped table-hover">
    <thead>
        <tr>
            <th width="50%">标题</th>
            <th width="30%">发布时间</th>
            <th width="20%">操作</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td><a href="/Article/Detail/@item.ID" title="@item.Name">@item.Name</a></td>
                <td>@item.AddTime</td>
                <td>
                    <a href='/Article/Edit/@item.ID'>编辑</a>
                    <a href="javascript:void(0);" onclick="btnDel(@item.ID)">删除</a>
                </td>
            </tr>
        }
    </tbody>
</table>

<script type="text/javascript">
    function btnDel(id){
        if(confirm("确认删除？")){
            var paramData={};
            paramData.id=id;
            $.ajax({
                type:'POST',
                url:'/Article/DelteArticle',
                data:paramData,
                dataType:'json',
                success:function(data){
                    if(data.code=='success'){
                        alert('删除成功');
                        window.location.href='/Article/Index';
                    }
                    else{
                        alert(data.msg);
                    }
                },
                error:function(ex){
                    alert('删除失败！');
                }
            });
        }
    }
</script>